import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/global.css'
import hljs from "highlight.js";
import 'highlight.js/styles/atom-one-dark.css'
import javascript from 'highlight.js/lib/languages/javascript';
import sql from 'highlight.js/lib/languages/sql';
import axios from 'axios'
import VueCopyToClipboard from 'vue-copy-to-clipboard'

hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('sql',sql)

Vue.prototype.$hljs = hljs;
Vue.prototype.$sql = sql;

Vue.config.productionTip = false
Vue.use(ElementUI,{size:'small'})
axios.defaults.withCredentials=true

Vue.directive('highlight', {
  deep: true,
  bind: function (el, binding) {
    // 将元素的 innerHTML 设置为高亮的代码
    el.innerHTML = hljs.highlightAuto(binding.value).value;
    // 添加行号显示功能
    // hljs.lineNumbersBlock(el);
  },
  componentUpdated: function (el, binding) {
    // 在组件更新后重新高亮代码块
    el.innerHTML = hljs.highlightAuto(binding.value).value;
    // hljs.lineNumbersBlock(el);
  }
});

Vue.component('vue-copy-to-clipboard', VueCopyToClipboard)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
